import ttkbootstrap as ttk
from core.GridBuilder import GridBuilder
from form.TestForm import TestForm
from form.SystemForm import SystemForm


if __name__ == "__main__":
    root = ttk.Window(themename="superhero")

    # 模拟用户数据
    users = [
        {"id": 1, "name": "张三", "age": "20"},
        {"id": 2, "name": "李四", "age": "25"},
        {"id": 3, "name": "王五", "age": "30"}
    ]

    users2 = [
        {"id": 4, "name": "赵六", "age": "35"},
        {"id": 5, "name": "孙七", "age": "40"},
        {"id": 6, "name": "周八", "age": "45"}
    ]

    # 创建 Notebook 组件
    notebook = ttk.Notebook(root)
    notebook.pack(fill=ttk.BOTH, expand=True)

    # 创建第一个标签页显示 users 数据
    tab1 = ttk.Frame(notebook)
    grid1 = GridBuilder(tab1, users)
    grid1.column('id', 'ID', sortable=True)
    grid1.column('name', '姓名')
    grid1.column('age', '年龄')
    grid1.height(30)
    grid1.action(TestForm)
    grid1.action(TestForm)
    grid1.tool(TestForm)
    grid1.setup_ui()
    notebook.add(tab1, text="账号管理")

    # 创建第二个标签页显示 users2 数据
    tab2 = ttk.Frame(notebook)
    grid2 = GridBuilder(tab2, users2)
    grid2.column('id', 'ID', sortable=True)
    grid2.column('name', '姓名')
    grid2.column('age', '年龄')
    grid2.height(30)
    grid2.action(TestForm)

    grid2.setup_ui()
    notebook.add(tab2, text="任务列表")


    # 创建系统设置标签页
    system_tab = ttk.Frame(notebook)
    system_form = SystemForm(system_tab)
    notebook.add(system_tab, text="系统设置")

    # 运行主循环
    root.mainloop()